package com.cskaoyan.controller.admin;

import com.cskaoyan.bean.vo.BaseRespVo;
import com.cskaoyan.bean.vo.StatGoodsVo;
import com.cskaoyan.bean.vo.StatOrderVo;
import com.cskaoyan.bean.vo.StatUserVo;
import com.cskaoyan.service.StatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: project2_market
 * @time: 2021/10/19
 * @author: yangshuai
 **/

@RestController
@RequestMapping("admin/stat")
public class StatController {

    @Autowired
    StatService statService;

    /**
     * 统计用户
     * @return
     */
    @RequestMapping("user")
    public BaseRespVo queryUser(){

        StatUserVo statUserVo = statService.selectUser();

        return BaseRespVo.ok(statUserVo);
    }

    /**
     * 订单统计
     * @return
     */
    @RequestMapping("order")
    public BaseRespVo queryOrder(){

        StatOrderVo statOrderVo = statService.selectOrder();

        return BaseRespVo.ok(statOrderVo);
    }

    /**
     * 商品统计
     * @return
     */
    @RequestMapping("goods")
    public BaseRespVo queryGoods(){

        StatGoodsVo statGoodsVo = statService.selectGoods();
//        String s = statGoodsVo.toString();    // 用来测试的

        return BaseRespVo.ok(statGoodsVo);
//        return BaseRespVo.ok();
    }

}
